package com.oa.office.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.spring.annotation.MapperScan;

import com.oa.office.entity.ReportTable;
import com.oa.office.entity.ReportTableWithBLOBs;

@MapperScan
public interface ReportTableMapper {
    @Delete({
        "delete from report_table",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into report_table (id, file_name, ",
        "creater, create_time, ",
        "updater, update_time, ",
        "state, report_time, ",
        "report_type, i_say, ",
        "head_say, spar2, ",
        "wait_work, off_work, ",
        "help, other, ",
        "spar, report_plan)",
        "values (#{id,jdbcType=INTEGER}, #{fileName,jdbcType=VARCHAR}, ",
        "#{creater,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{updater,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{state,jdbcType=INTEGER}, #{reportTime,jdbcType=DATE}, ",
        "#{reportType,jdbcType=VARCHAR}, #{iSay,jdbcType=INTEGER}, ",
        "#{headSay,jdbcType=INTEGER}, #{spar2,jdbcType=VARCHAR}, ",
        "#{waitWork,jdbcType=LONGVARCHAR}, #{offWork,jdbcType=LONGVARCHAR}, ",
        "#{help,jdbcType=LONGVARCHAR}, #{other,jdbcType=LONGVARCHAR}, ",
        "#{spar,jdbcType=LONGVARCHAR}, #{reportPlan,jdbcType=LONGVARCHAR})"
    })
    int insert(ReportTableWithBLOBs record);

    @InsertProvider(type=ReportTableSqlProvider.class, method="insertSelective")
    int insertSelective(ReportTableWithBLOBs record);

    @Select({
        "select",
        "id, file_name, creater, create_time, updater, update_time, state, report_time, ",
        "report_type, i_say, head_say, spar2, wait_work, off_work, help, other, spar, ",
        "report_plan",
        "from report_table",
        "where spar like #{spar,jdbcType=LONGVARCHAR}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="file_name", property="fileName", jdbcType=JdbcType.VARCHAR),
        @Result(column="creater", property="creater", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updater", property="updater", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="state", property="state", jdbcType=JdbcType.INTEGER),
        @Result(column="report_time", property="reportTime", jdbcType=JdbcType.DATE),
        @Result(column="report_type", property="reportType", jdbcType=JdbcType.VARCHAR),
        @Result(column="i_say", property="iSay", jdbcType=JdbcType.INTEGER),
        @Result(column="head_say", property="headSay", jdbcType=JdbcType.INTEGER),
        @Result(column="spar2", property="spar2", jdbcType=JdbcType.VARCHAR),
        @Result(column="wait_work", property="waitWork", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="off_work", property="offWork", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="help", property="help", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="other", property="other", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="spar", property="spar", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="report_plan", property="reportPlan", jdbcType=JdbcType.LONGVARCHAR)
    })
    ReportTableWithBLOBs selectReportTableLikeSpar(String spar);
    
    @Select({
        "select",
        "id, file_name, creater, create_time, updater, update_time, state, report_time, ",
        "report_type, i_say, head_say, spar2, wait_work, off_work, help, other, spar, ",
        "report_plan",
        "from report_table",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="file_name", property="fileName", jdbcType=JdbcType.VARCHAR),
        @Result(column="creater", property="creater", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updater", property="updater", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="state", property="state", jdbcType=JdbcType.INTEGER),
        @Result(column="report_time", property="reportTime", jdbcType=JdbcType.DATE),
        @Result(column="report_type", property="reportType", jdbcType=JdbcType.VARCHAR),
        @Result(column="i_say", property="iSay", jdbcType=JdbcType.INTEGER),
        @Result(column="head_say", property="headSay", jdbcType=JdbcType.INTEGER),
        @Result(column="spar2", property="spar2", jdbcType=JdbcType.VARCHAR),
        @Result(column="wait_work", property="waitWork", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="off_work", property="offWork", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="help", property="help", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="other", property="other", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="spar", property="spar", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="report_plan", property="reportPlan", jdbcType=JdbcType.LONGVARCHAR)
    })
    ReportTableWithBLOBs selectReportTableById(int id);
    
    @Select({
        "select",
        "id, file_name, creater, create_time, updater, update_time, state, report_time, ",
        "report_type, i_say, head_say, spar2, wait_work, off_work, help, other, spar, ",
        "report_plan",
        "from report_table",
        "where report_type = #{reportType,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="file_name", property="fileName", jdbcType=JdbcType.VARCHAR),
        @Result(column="creater", property="creater", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updater", property="updater", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="state", property="state", jdbcType=JdbcType.INTEGER),
        @Result(column="report_time", property="reportTime", jdbcType=JdbcType.DATE),
        @Result(column="report_type", property="reportType", jdbcType=JdbcType.VARCHAR),
        @Result(column="i_say", property="iSay", jdbcType=JdbcType.INTEGER),
        @Result(column="head_say", property="headSay", jdbcType=JdbcType.INTEGER),
        @Result(column="spar2", property="spar2", jdbcType=JdbcType.VARCHAR),
        @Result(column="wait_work", property="waitWork", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="off_work", property="offWork", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="help", property="help", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="other", property="other", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="spar", property="spar", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="report_plan", property="reportPlan", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<ReportTableWithBLOBs> selectByPrimaryKey(String reportType);

    @UpdateProvider(type=ReportTableSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(ReportTableWithBLOBs record);

    @Update({
        "update report_table",
        "set file_name = #{fileName,jdbcType=VARCHAR},",
          "creater = #{creater,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "updater = #{updater,jdbcType=VARCHAR},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "state = #{state,jdbcType=INTEGER},",
          "report_time = #{reportTime,jdbcType=DATE},",
          "report_type = #{reportType,jdbcType=VARCHAR},",
          "i_say = #{iSay,jdbcType=INTEGER},",
          "head_say = #{headSay,jdbcType=INTEGER},",
          "spar2 = #{spar2,jdbcType=VARCHAR},",
          "wait_work = #{waitWork,jdbcType=LONGVARCHAR},",
          "off_work = #{offWork,jdbcType=LONGVARCHAR},",
          "help = #{help,jdbcType=LONGVARCHAR},",
          "other = #{other,jdbcType=LONGVARCHAR},",
          "spar = #{spar,jdbcType=LONGVARCHAR},",
          "report_plan = #{reportPlan,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(ReportTableWithBLOBs record);

    @Update({
        "update report_table",
        "set file_name = #{fileName,jdbcType=VARCHAR},",
          "creater = #{creater,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "updater = #{updater,jdbcType=VARCHAR},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "state = #{state,jdbcType=INTEGER},",
          "report_time = #{reportTime,jdbcType=DATE},",
          "report_type = #{reportType,jdbcType=VARCHAR},",
          "i_say = #{iSay,jdbcType=INTEGER},",
          "head_say = #{headSay,jdbcType=INTEGER},",
          "spar2 = #{spar2,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ReportTable record);
    @Select("select * from report_table where creater=#{name,jdbcType=VARCHAR}")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="file_name", property="fileName", jdbcType=JdbcType.VARCHAR),
        @Result(column="creater", property="creater", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updater", property="updater", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="state", property="state", jdbcType=JdbcType.INTEGER),
        @Result(column="report_time", property="reportTime", jdbcType=JdbcType.DATE),
        @Result(column="report_type", property="reportType", jdbcType=JdbcType.VARCHAR),
        @Result(column="i_say", property="iSay", jdbcType=JdbcType.INTEGER),
        @Result(column="head_say", property="headSay", jdbcType=JdbcType.INTEGER),
        @Result(column="spar2", property="spar2", jdbcType=JdbcType.VARCHAR),
        @Result(column="wait_work", property="waitWork", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="off_work", property="offWork", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="help", property="help", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="other", property="other", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="spar", property="spar", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="report_plan", property="reportPlan", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<ReportTableWithBLOBs> findByEmpName(String name);
}